package net.wds.ssbus.modules.dict.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.wds.ssbus.common.utils.PageUtils;
import net.wds.ssbus.common.utils.R;
import net.wds.ssbus.modules.dict.entity.TbBaseDictitemEntity;
import net.wds.ssbus.modules.dict.service.TbBaseDictitemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/data")

public class TreeController {
    @Autowired
    TbBaseDictitemService tbBaseDictitemService;

    @RequestMapping("/children/{id}")
    public R getlist(@PathVariable("id") Integer id, @RequestParam Map<String, Object> param){
        PageUtils page = tbBaseDictitemService.getChildren(param, id);
        return R.ok().put("page",page) ;
    }

    @RequestMapping("/childrens/{id}")
    public R getallList(@PathVariable("id") Integer id){
        List<TbBaseDictitemEntity> list = tbBaseDictitemService.list(new QueryWrapper<TbBaseDictitemEntity>().eq("parent_id", id));
        return R.ok().put("list",list) ;
    }
}